package jdbc;

import jdbc.util.InputUtil;

import java.sql.SQLException;

public class RegUserDemo {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
//        System.out.println("注册用户");
//        System.out.println("请输入用户名：");
//        String username = new Scanner(System.in).next();
//        System.out.println("请输入密码：");
//        String password = new Scanner(System.in).next();
//        System.out.println("请输入昵称：");
//        String nickname = new Scanner(System.in).next();
//        System.out.println("请输入年龄：");
//        int age = new Scanner(System.in).nextInt();

        User user = InputUtil.getInputObject(new User(),"欢迎注册");
        System.out.println(user);


//        Class.forName("com.mysql.cj.jdbc.Driver");
//        System.out.println("开始连接数据库");
//        long start = System.currentTimeMillis();
//        Connection conn = DriverManager.getConnection(
//                "jdbc:mysql://localhost:8164/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
//                "root",
//                "123457");
//        Statement stmt = conn.createStatement();
//        System.out.println("连接成功,耗时" + (System.currentTimeMillis() - start) + "ms");
//        /*连接数据库-----------------------------------------------------------*/
//        String sql = "insert into user(username,password,nickname,age) " +
//                "values('" + username + "','" + password + "','" + nickname + "'," + age + ")";
//        stmt.executeUpdate(sql);
//        System.out.println("注册成功");
//        stmt.close();
    }
}
